<?php

$get = $_GET;

if (isset($get['action'])) {
    $get['action'] = $get['action'];
} else {
    $get['action'] = 'seller';
}

$data = file_get_contents("./data.json");
$data =  json_decode($data, true);

header('Content-type: application/json');
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header('Access-Control-Allow-Headers:x-requested-with,content-type');
switch ($get['action']) {
    case 'seller':
        echo returnData($data['seller']);
        break;
    case 'goods':
        echo returnData($data['goods']);
        break;
    case 'ratings':
        echo returnData($data['ratings']);
        break;
    default:
        echo returnData($data);
        break;
}

function returnData($data, $errNo = 0)
{
    return json_encode(['errno' => $errNo, 'data' => $data]);
}

